<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>后台管理模板</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="@{'/public/plugins/layui/css/layui.css'}"
	media="all">
<link rel="stylesheet" href="@{'/public/css/sweetalert2.min.css'}">
<script src="@{'public/plugins/layui_new/layui.js'}"></script>
<script src="@{'public/js/jquery-2.1.4.min.js'}"></script>
<script src="@{'public/js/sweetalert2.min.js'}"></script>



</head>
<body>
	<!-- 内容主体区域 -->

	<div style="padding: 15px;">
		<ul class="layui-tab-title">

			<button id='add' class="layui-btn" onclick="updateDataShow(-1)">
				<i class="layui-icon">&#xe608;</i> 添加新闻
			</button>
		</ul>
		<table class="layui-table">
			<thead>
				<tr>
					<th lay-data="{field:'id', width:80, sort: true}">ID</th>
					<th lay-data="{field:'name', width:200, sort: true}">标题</th>
					<th lay-data="{field:'name', width:200, sort: true}">图片</th>
					<th lay-data="{field:'name', width:200, sort: true}">作者</th>
					<th lay-data="{field:'name', width:200, sort: true}">链接</th>
					<th lay-data="{field:'name', width:200, sort: true}">时间</th>
					<th lay-data="{field:'name', width:200, sort: true}">是否启用</th>
		
					<th lay-data="{field:'bianji', width:150}">操作</th>
				</tr>
			</thead>
			#{list items:page.result,as:'item'}
			<tr>
				<td>${item.id}</td>
				<td>${item.title}</td>
				
				<td>
					<img src="${item.img}" height="25px" width="50px"></img>
				</td>
				
				<td>${item.author}</td>
				<td>${item.links}</td>
				
				<td>${item.createDate.format('yyyy-MM-dd hh:mm:ss')}</td>
				
				<td>
				
					 #{if item.isShow=='1'}
					    <i class="layui-icon" style="font-size: 30px; color: #1E9FFF;"> &#xe616;</i>
					    #{/if}
					    #{else}
					    <i class="layui-icon" style="font-size: 30px; color: #999999;">  &#x1007;</i>
					    #{/else}
					    
				</td>
				
			
				<td><a href="javascript:updateDataShow(${item.id})"
					target="_blank" class="layui-btn layui-btn-normal layui-btn-mini">编辑</a>
					<a href="javascript:deleteById(${item.id})"
					class="layui-btn layui-btn-mini layui-btn-warm">删除</a></td>
			</tr>
			#{/list}
		</table>
	</div>
		
            
            
           
            

	<script>
		//JavaScript代码区域
		layui.use('element', function() {
			var element = layui.element;
			

		});
	</script>

	<script>
		layui.use([ 'layer', 'form' ], function() {
			var layer = layui.layer, form = layui.form;
			
		});

		layui.use('table', function() {
			var table = layui.table;

		});
		

		function deleteById(id) {
			layer
					.confirm(
							'<span  style="font-size:12px;color:red">(删除一级目录,会删除与之有关联的二级目录及商品)</span></br>确认删除吗？',
							{
								btn : [ '确定', '关闭' ]
							},
							function() {
								$.ajax({url : "@{manage.deleteCommById()}",
										type : "GET",
										async : false,
										data : {
											"id" : id
										},
										dataType : "text",
										success : function(data) {
												if (data) {
													layer
															.confirm(
																	'删除成功！</br>',
																	{
																		btnAlign : 'c',
																		btn : [ '确定' ]
																	},
																	function() {
																		window.location.href = "/indexManage";
																	});
												} else {
													layer.alert("删除失败!");
												}
											},
											error : function(data) {
												layer
														.alert("您的账户可能出现异常，请重新刷新获取账号信息!");
											}
										})
							});
		}
		
		
		

		function updateDataShow(id){
			
			window.location.href="@{manage.addOrUpNews()}?id="+id;
			
			
		}


		
		
	</script>

</body>
</html>